package org.wattdepot.cli.commands;

import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.wattdepot.cli.CommandLineInterface;
import org.wattdepot.client.WattDepotClient;

/**
 * Test case for the SensorDataCommand.
 * 
 * @author Paul Galiza
 * 
 */
public class TestSensorDataCommand {
  private CommandLineInterface cli = new CommandLineInterface();
  private WattDepotClient client = cli.getClient();
  private SensorDataCommand sensorData = new SensorDataCommand();
  
  /**
   * Tests the number of buffer appends.
   */
  @Test
  public void testReturn() {
    List<String> userInput = new ArrayList<String>();
    userInput.add("");
    userInput.add("SIM_KAHE_5");
    userInput.add("");
    userInput.add("2009-11-01T12:00:00.000-10:00");
    sensorData.doCommand(userInput, client);
    double actual = sensorData.getTestBufferAppend();
    System.out.println(actual);
    assertEquals("Testing proper number of buffer appends!", 7.0, actual, 0);
  }

  /**
   * Test to see if the validation checker works.
   * 
   * @throws Exception NotAuthorizedException, ResourceNotFoundException, BadXmlException,
   *                   MiscClientException.
   */
  @Test
  public void validityTest() throws Exception {
    List<String> userInput = new ArrayList<String>();
    userInput.add("");
    userInput.add("Test_Source");// invalid source

    String actual = sensorData.doCommand(userInput, client);
    assertEquals("Testing source validity!", "Invalid Source", actual);
    
    userInput.add(1, "SIM_KAHE");
    userInput.add(3, "1");
    actual = sensorData.doCommand(userInput, client);
    assertEquals("Testing source validity!", "Invalid timestamp", actual);

  }
}
